<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<script src="<c:url value='/js/search_valid.js'/>"></script>
<!--/span-->
<div class="page-header">
	<h3 style="margin-top: auto">检索接口</h3>
	<form class="form-search" action="<%=request.getContextPath()%>/interface/search"
			method="POST" onsubmit="return valid();">
		<div class="input-append"><input type="text" class="span2 search-query" id="searchText" name="searchText"
				style="width: 600px">
			<button type="submit" class="btn"><i class="icon-search"></i>&nbsp;检索</button>
		</div>
	</form>
</div>
<div class="row-fluid">
	<div>
		<c:choose>
			<c:when test="${!empty bean}">
				<table class="table table-hover" style="width:80%">
					<thead>
						<tr>
							<th>编号</th>
							<th>名称</th>
							<th>类别</th>
							<th>创建者</th>
							<!-- <th>描述信息</th> -->
							<th>操作
								<div style="float: right;">
									<button class="btn btn-small"
										onclick="window.location.href='<%=request.getContextPath()%>/interface/add';"><i class="icon-plus"></i>&nbsp;创建接口</button>
								</div>
							</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${bean.getList()}" var="list" varStatus="s">
							<tr>
								<td><c:out value="${s.count}" /></td>
								<td><c:out value="${list.name}" /></td>
								<td><c:out value="${list.itype}" /></td>
								<td><c:out value="${list.owner.username}" /></td>
								<%-- <td><c:out value="${list.description}" /></td> --%>
								<td><c:set var="muri" value="${fn:replace(list.uri,':', '/')}" />
								<div class="btn-group">
										<button class="btn"
											onclick="window.location.href='<%=request.getContextPath()%>/${muri}/update';"><i class="icon-edit"></i>&nbsp;编辑</button>
										<button class="btn"
											onclick="window.location.href='<%=request.getContextPath()%>/${muri}/download';"><i class="icon-download"></i>&nbsp;下载</button>
										<button class="btn"
											onclick="window.location.href='<%=request.getContextPath()%>/${muri}';"><i class="icon-search"></i>&nbsp;详细信息</button>
									</div></td>
							</tr>
						</c:forEach>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="8">
								<div class="pagination pagination-centered">
									<c:set value="${bean.getCurrentPage()}" var="currentPNum"
										scope="page"></c:set>
									<c:set value="${bean.getTotalPage()}" var="totalSize"
										scope="page"></c:set>
									<ul>
										<c:choose>
											<c:when test="${currentPNum == 1}">
												<li class="disabled"><a href="javascript:void(0);">&laquo;</a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/interface?pageNum=${currentPNum-1}">&laquo;</a></li>
											</c:otherwise>
										</c:choose>
										<li class="active"><a href="javascript:void(0);"><c:out
													value="${currentPNum}" /></a></li>
										<c:choose>
											<c:when test="${currentPNum+1 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+1}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/interface?pageNum=${currentPNum+1}"><c:out
															value="${currentPNum+1}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+2 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+2}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/interface?pageNum=${currentPNum+2}"><c:out
															value="${currentPNum+2}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+3 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+3}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/interface?pageNum=${currentPNum+3}"><c:out
															value="${currentPNum+3}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+4 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);"><c:out
															value="${currentPNum+4}" /></a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/interface?pageNum=${currentPNum+4}"><c:out
															value="${currentPNum+4}" /></a></li>
											</c:otherwise>
										</c:choose>
										<c:choose>
											<c:when test="${currentPNum+1 > totalSize}">
												<li class="disabled"><a href="javascript:void(0);">&raquo;</a></li>
											</c:when>
											<c:otherwise>
												<li><a
													href="<%=request.getContextPath()%>/interface?pageNum=${currentPNum+1}">&raquo;</a></li>
											</c:otherwise>
										</c:choose>
									</ul>
								</div>
							<td>
					</tfoot>
				</table>
			</c:when>
			<c:otherwise>
				<h3 style="margin-top: auto">数据库暂无相关接口信息</h3>
			</c:otherwise>
		</c:choose>
	</div>
</div>